<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>动态渲染表格</title>
</head>
<body>
  <table border="1">
      <thead>
        <th>ID</th>
        <th>名字</th>
        <th>年龄</th>
      </thead>
  </table>

  <script>
      var users = [
          {id:1,name:'cty',age:18},
          {id:2,name:'nihao',age:20},
          {id:3,name:'js',age:80}
      ];
      var tbody = document.createElement('tbody');
      users.forEach(function (value) {
          var tr = document.createElement('tr');
          for (var key in value) {
              var td = document.createElement('td');
              td.innerText = value[key];
              tr.appendChild(td);
          }
          tbody.appendChild(tr);
      })
      var table = document.querySelector('table');
      table.appendChild(tbody);
  </script>
</body>
</html>